home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / datatypes / binarydt / source / subs.c < prev    next >
C/C++ Source or Header  |  1996-04-07  |  3KB  |  111 lines

  1. /*
  2. ** $PROJECT: binary.datatype
  3. **
  4. ** $VER: subs.c 39.1 (11.02.95)
  5. **
  6. ** by
  7. **
  8. ** Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
  9. **
  10. ** (C) Copyright 1995
  11. ** All Rights Reserved !
  12. **
  13. ** $HISTORY:
  14. **
  15. ** 11.02.95 : 039.001 : initial
  16. */
  17.  
  18. #include "classbase.h"
  19.  
  20. /* -------------------------- support functions --------------------------- */
  21.  
  22. /*FS*/ ULONG notifyAttrChanges(Object * obj, void * ginfo, ULONG flags, ULONG tag1,...)
  23. {
  24.      return(DoMethod(obj, OM_NOTIFY, &tag1, ginfo, flags));
  25. }
  26. /*FE*/
  27. /*FS*/ ULONG setSuperAttrs(Class *cl,Object * obj, void *ginfo,ULONG tag1,...)
  28. {
  29.      return(DoSuperMethod(cl,obj, OM_SET, &tag1, ginfo));
  30. }
  31. /*FE*/
  32. /*FS*/ ULONG setAttrs(Object * obj, void *ginfo,ULONG tag1,...)
  33. {
  34.      return(DoMethod(obj, OM_SET, &tag1, ginfo));
  35. }
  36. /*FE*/
  37. /*FS*/ ULONG updateAttrs(Object * obj, void *ginfo,ULONG tag1,...)
  38. {
  39.      return(DoMethod(obj, OM_UPDATE, &tag1, ginfo));
  40. }
  41. /*FE*/
  42.  
  43. /* ----------------------- async method invokation ------------------------ */
  44.  
  45. /*FS*/ ULONG DoAsyncMethod(Object *obj,Msg msg,ULONG tag1,...)
  46. {
  47.     return(DoAsyncMethodA(obj,msg,(struct TagItem *) &tag1));
  48. }
  49. /*FE*/
  50. /*FS*/ /*"ULONG DoAsyncMethodA(Object *obj,Msg msg,struct TagItem *tagList)"*/
  51.  
  52. struct AsyncMethodMsg
  53. {
  54.     struct Message amm_ExecMessage;
  55.     Object *amm_Object;
  56.     Msg amm_Msg;
  57. };
  58.  
  59. ULONG DoAsyncMethodA(Object *obj,Msg msg,struct TagItem *tagList)
  60. {
  61.     Class *cl = OCLASS(obj);
  62.     struct ClassBase *cb = (struct ClassBase *) cl->cl_UserData;
  63.     struct AsyncMethodMsg amsg;
  64.     struct Process *proc = NULL;
  65.     struct MsgPort *mport;
  66.     ULONG retval = FALSE;
  67.  
  68.     if((mport = CreateMsgPort()))
  69.     {
  70.         amsg.amm_Object = obj;
  71.         amsg.amm_Msg    = msg;
  72.  
  73.         amsg.amm_ExecMessage.mn_Node.ln_Type = NT_MESSAGE;
  74.         amsg.amm_ExecMessage.mn_ReplyPort    = mport;
  75.  
  76.         if((proc = CreateNewProcTags(NP_Entry,asyncmethodfunc,
  77.                                               (tagList) ? TAG_MORE : TAG_IGNORE,tagList,
  78.                                               TAG_DONE)))
  79.         {
  80.             D(bug("sending object : %lx, msg : %lx\n",obj,msg));
  81.  
  82.             PutMsg(&proc->pr_MsgPort,&amsg.amm_ExecMessage);
  83.             WaitPort(mport);
  84.             retval = TRUE;
  85.         }
  86.  
  87.         DeleteMsgPort(mport);
  88.     }
  89.     return((ULONG) proc);
  90. }
  91.  
  92. ClassCall ULONG asyncmethodfunc(void)
  93. {
  94.     struct Process *proc = (struct Process *) FindTask(NULL);
  95.     Object *obj;
  96.     Msg msg;
  97.     struct AsyncMethodMsg *amsg;
  98.  
  99.     WaitPort(&proc->pr_MsgPort);
  100.     amsg = (struct AsyncMethodMsg *) GetMsg(&proc->pr_MsgPort);
  101.     obj = amsg->amm_Object;
  102.     msg = amsg->amm_Msg;
  103.     ReplyMsg(&amsg->amm_ExecMessage);
  104.  
  105.     D(bug("recieved object : %lx, msg : %lx\n",obj,msg));
  106.  
  107.     return(DoMethodA(obj,msg));
  108. }
  109. /*FE*/
  110.  
  111.